home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0" encoding="utf-8"?>
- <!-- ===========================================================
- Category: HTML
- Sub-category: TextBox
- Author: David Silverlight
- HeadGeek@xmlpitstop.com
- Created: 2001-05-16
- Description:-
- This series of textboxes is generated using the pull method
- of extracting xml elements. Each element will generate a
- text box. Also note that we are using the Pull method to
- extract data from our xml document. The pull method is an
- approach where the use of templates is minimized and data
- is accessed by 'pulling' it from our xml document
- ================================================================ -->
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
- <xsl:output method="html" />
-
- <xsl:template match="/">
- <html>
- <head>
- <style type="text/css">
- H1 {COLOR: red; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
- H2 {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
- .head {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
- .subhead {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
- .text {COLOR: black; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
- TH {COLOR: white; FONT-FAMILY: Arial; background-color: darkblue;}
- TD {COLOR: darkblue; FONT-FAMILY: Arial}
- TR { background-color: beige; }
- BODY { background-color: beige; }
- </style>
- </head>
- <body>
- <h1>Generating a text box from xml (Pull Method)</h1>
- <xsl:for-each select="/employees/employee">
- <!-- The following for-each loop will iterate through all of the child elements
- of employee -->
- <xsl:for-each select="*">
- <xsl:value-of select="name(.)" />
-
- <xsl:element name="Input">
- <!-- Set the Size of the textbox -->
- <xsl:attribute name="size">
- <xsl:value-of select="string-length(.)" />
- </xsl:attribute>
-
- <!-- Set the Size of the textbox -->
- <xsl:attribute name="maxlength">
- <xsl:value-of select="string-length(.) + 5" />
- </xsl:attribute>
-
- <!-- Set the value of the text box -->
- <xsl:attribute name="value">
- <xsl:value-of select="text()" />
- </xsl:attribute>
-
- <br />
- </xsl:element>
- </xsl:for-each>
- </xsl:for-each>
- </body>
- </html>
- </xsl:template>
- </xsl:stylesheet>
-